import axios from 'axios';

const parseCookie = (cookies) => {
	let cookie = '';
	Object.keys(cookies).forEach((item) => {
		cookie += item + '=' + cookies[item] + ';';
	});
	return cookie;
};

export default {
	get ({url, params, cookies}) {
		const cookie = parseCookie(cookies);
		return axios({
			method: 'get',
			url,
			params,
			headers: {
				'X-Requested-With': 'XMLHttpRequest',
				cookie
			}
		});
	}
};
